{extend name="public/base"/}
{block name="style"}
{/block}
{block name="content"}
    <div class="data-list" data-url="{:url('index')}">
        <form class="layui-form inline-form">
            <div class="pull-left">
                <div class="layui-inline">
                    <input class="layui-input laydate-range" autocomplete="off" name="create_time" placeholder="录入时间">
                </div>
                <div class="layui-inline">
                    <select name="channel_id" lay-search lay-filter="data-list">
                        <option value="">渠道</option>
                        {foreach $channel as $c}
                        <option value="{$c.channel_id}">{$c.channel_name}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm layui-btn-normal search"><i class="layui-icon layui-icon-search"></i></button>
                </div>
            </div>
            <div class="pull-right">
                <div class="layui-inline">
                    <button title="添加可走属性配置" class="layui-btn layui-btn-normal layui-btn-sm ajax-form" width-form="80%" data-url="{:url('add')}"><i class="layui-icon layui-icon-add-circle"></i> 新增</button>
                </div>
            </div>
        </form>
        <div class="data">
            <p><i class="fa fa-spinner fa-spin"></i> 加载中...</p>
        </div>
    </div>
{/block}
{block name="script"}
<script type="text/javascript">
    //一般直接写在一个js文件中
    layui.extend({
        xmSelect: 'xm-select'
    }).use(['layer', 'form', 'jquery', 'longli', 'xmSelect'], function()
    {
        var layer = layui.layer
            , form = layui.form
            , $ = layui.jquery;
    });
    /**
     * 渲染多选下拉框
     * @param node 需要渲染的节点
     * @param args 配置项
     * @param defVal 默认值
     */
    function renderSearch(node, args, defVal)
    {
        var xargs = {
            el: node,
            data: [],
            prop: {
                name: args.prop.name,
                value: args.prop.value,
            },
            name: args.name,
            filterable: true,
            remoteSearch: true,
            remoteMethod: function (text, callback, show)
            {
                text = text.trim();
                var param = {more: 1};
                param[args.search] = text;
                $.post(args.remoteUrl, param).done(function (response)
                {
                    if(response.code != 1) return callback([]);
                    callback(response.data);
                });
            }
        };
        if(defVal)
        {
            for(let i in defVal)
            {
                var param = {};
                param[defVal[i].id.key] = defVal[i].id.value;
                param[defVal[i].name.key] = defVal[i].name.value;
                param["selected"] = true;
                xargs.data.push(param);
            }
        }
        layui.xmSelect.render(xargs);
    }
</script>
{/block}